package com.study.lxy.exames;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

public class Test2 {

    public static void main(String[] args) throws Exception {
        int count = 3;
        //int[][] realtions = {{1,2},{2,3},{3,4},{4,1}};
        int[][] realtions = {{1,2},{2,3},{1,3}};
        Set<Integer> classSet = new HashSet<Integer>();
        int relationCount = 0;
        for(int[] nodeRelation : realtions){

            int i = 0;
            for(Integer node : nodeRelation){
                classSet.add(node);
                if(i >= 1){
                    relationCount++;
                }
                i++;
            }
        }

        if(classSet.size() < count){
            throw new Exception("class count less then need learn");
        }

        if(relationCount >= classSet.size()){
            throw new Exception("存在互相依赖");
        }

        ReentrantLock lock = new ReentrantLock();
        Condition condition = lock.newCondition();
        condition.signal();

        AtomicReference atomicReference = new AtomicReference();
        ThreadLocal<String> str = new ThreadLocal<String>();
        str.set("aaa");

    }
}
